import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';

//import 'package:ivc/views/assets/asset_page.dart';
import 'package:ivc/views/factory/biz_list.dart';
//import 'package:ivc/views/web_page/web_view_page.dart';
import 'package:ivc/views/home.dart';
//import 'package:ivc/views/login_page/login_page.dart';
import 'package:ivc/model/user_info.dart';
//import 'package:ivc/views/collection_page/collection_page.dart';
//import 'package:ivc/views/collection_page/collection_full_page.dart';
//import 'package:ivc/views/standard_demo_page/index.dart';
//import 'package:ivc/views/issuse_message_page/issuse_message_page.dart';
import '../views/parts/parts_item_page.dart';
import '../views/lending/lending_item_page.dart';
import "../views/lending/lend_now.dart";
import "../views/mr/mr_order_page.dart";
import "../views/mr/mr_request_page.dart";
import "../views/manufacture/make_now.dart";
import "../views/manufacture/check_split.dart";
import '../views/manufacture/orders_overview.dart';
import '../views/tools/scanner.dart';
import '../views/assets/asset_page.dart';
import '../views/assets/connect_now.dart';
import '../views/factory/gain_order_capability.dart';
import '../views/role/factory_owner.dart';
import '../views/iiot/iiot_portal.dart';
import 'package:ivc/views/tipcard/tip_card.dart';
import 'package:ivc/views/role/demo_change_role.dart';


// app的首页
var demoChangeRoleHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return new DemoChangeRolePage();
  },
);


// app的首页
var homeHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return new AppPage(UserInformation(id: 0));
  },
);

var iiotPortalHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return  IIoTPortal();
  },
);

var tipCardHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return  TipCard();
  },
);

var partsItemPageHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    bool readonly = (params['readonly']?.first)?.toLowerCase() == 'true';
    return PartsItemPage(id: id, readonly: readonly);
  },
);


var lendingItemPageHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    bool readonly = (params['readonly']?.first)?.toLowerCase() == 'true';
    return LendingItemPage(id: id, readonly: readonly);
  },
);
var lendNowPageHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    return LendNowPage(id: id);

  },
);

var checkSplitHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    return CheckSplitPage(id: id);

  },
);

var ordersOverviewHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return OrdersOverview();

  },
);


var bizListHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int tab = int.tryParse(params['tab']?.first);
    return OrderList(tab: tab);
  },
);


var mrOrderPageHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    bool readonly = (params['readonly']?.first)?.toLowerCase() == 'true';
    return MROrderPage(id: id, readonly: readonly);
  },
);


var placeOrderHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MakeNowPage();
  },
);

var createMRRequestHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MRRequestPage();
  },
);


var scannerHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ScannerPage();
  },
);

var assetPageHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return AssetPage();
  },
);


var factoryGainOrderCapabilityHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return GainOrderCapabilityPage();
  },
);

var connectNowHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ConnectNowPage();
  },
);





var roleFactoryOwnerHandler = new Handler(
  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return FactoryOwnerPage();
  },
);







var loginPageHandler = new Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
//      return LoginPage();
    return Text("");
    });

//var webViewPageHand = new Handler(
//    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
//  String title = params['title']?.first;
//  String url = params['url']?.first;
//  return new WebViewPage(url, title);
//});
//
//
//var standardPageHandler = new Handler(
//  handlerFunc: (BuildContext context, Map<String, List<String>> params) {
//    String id = params['id']?.first;
//    return StandardView(id: id);
//  }
//);


//var issuesMessageHandler = new Handler(
//    handlerFunc: (BuildContext context, Map<String, List<String>> params) {
//      return IssuesMessagePage();
//    });
